//
//  HelpView.m
//  easyTaxi
//
//  Created by ellenpage on 13-1-22.
//  Copyright (c) 2013年 ellenpage. All rights reserved.
//

#import "HelpView.h"
#import "Constant.h"

@interface HelpView ()<UIScrollViewDelegate>


@end

@implementation HelpView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self = [[[NSBundle mainBundle] loadNibNamed:@"HelpView" owner:self options:nil] objectAtIndex:0];
        [self initialData];
    }
    return self;
}

-(void)initialData
{
    _helpSView.delegate = self;
    _helpSView.pagingEnabled = YES;
    _helpSView.showsHorizontalScrollIndicator = NO;
    _helpSView.showsVerticalScrollIndicator   = NO;
    
    if (!iP5)
    {
        [_helpSView setContentSize:CGSizeMake(320 * 5, 480)];
        
        for (int i = 0; i < 4; i ++)
        {
            CGRect rect = CGRectMake(0 + i * 320, 0, 320, 480);
            UIImageView *imgView = [[UIImageView alloc] initWithFrame:rect];
            
            NSString *nameStr = [NSString stringWithFormat:@"guide%d.jpg",i+1];
            imgView.image = [UIImage imageNamed:nameStr];
            
            [_helpSView addSubview:imgView];
        }
    }
    else
    {
        [_helpSView setContentSize:CGSizeMake(320 * 5, 568)];
        
        self.backgroundColor = [UIColor darkTextColor];

        for (int i = 0; i < 4; i ++)
        {
            CGRect rect = CGRectMake(0 + i * 320, 44, 320, 480);
            UIImageView *imgView = [[UIImageView alloc] initWithFrame:rect];
            
            NSString *nameStr = [NSString stringWithFormat:@"guide%d.jpg",i+1];
            imgView.image = [UIImage imageNamed:nameStr];

            [_helpSView addSubview:imgView];
        }        
    }
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{    
    if (scrollView.contentOffset.x == 320*4)
    {
        self.hidden = YES;
    }
}

-(void)showHelpView
{
    [_helpSView setContentOffset:CGPointMake(0, 0)];
    self.hidden = NO;
}

@end
